package com.example.a10928.weifriend.http.configuration;

import android.content.Context;
import android.view.View;


import com.example.a10928.weifriend.util.Utils;

import java.io.IOException;

/**
 * Created by Chuang on 2018/2/28.
 * 请声明此类的作用，如无声明则留null
 */

public class ApiException extends IOException {


    /**
     * 返回码	返回信息	说明
     * 200	代表操作成功或验证通过等
     * 4001	操作失败,处理失败,逻辑错误等
     * 1001	缺少token
     * 1002	token不正确,用户未登录
     * 1003	token已过期,请重新登录!
     * 1004	参数错误
     * 1005	账号或密码不正确
     * 1006	该手机号未注册,请重新输入
     * 1007	该手机号已被注册
     * 1008	两次密码不一致
     * 1009	昵称已被占用
     * 1010	验证码错误
     * 1011	验证码过期
     * 1012	验证码重复发送
     * 1013	密码错误
     * 1014	邮箱已被使用
     * 1015	该身份证已被认证
     * 1016	图片大小或格式不正确
     */
    public static final int CODE_OK = 200;
    public static final int BLACK_LIST = 500;
    public static final int CODE_OPERATION_FAILURE = 4001; //操作失败,处理失败,逻辑错误等
    public static final int CODE_NO_TOKEN = 1001;   //缺少token
    public static final int CODE_TOKEN_ERROR = 1002;    //token不正确,用户未登录
    public static final int CODE_TOKEN_PAST_DUE = 1003;  //token已过期,请重新登录!
    public static final int CODE_PARAMETER_ERROR = 1004;    //参数错误
    public static final int CODE_ACCOUNT_PASSWORD_ERROR = 1005; //账号或密码不正确
    public static final int CODE_PHONE_UNREGISTERED = 1006;     //该手机号未注册,请重新输入
    public static final int CODE_PHONE_REGISTERED = 1007;   //该手机号已被注册
    public static final int CODE_ENTERED_PASSWORDS_DIFFER = 1008;   //两次密码不一致
    public static final int CODE_NAME_ALREADY_EXISTS = 1009;    //昵称已被占用
    public static final int CODE_CODE_ERROR = 1010; //验证码错误
    public static final int CODE_CODE_PAST_DUE = 1011;  //验证码过期
    public static final int CODE_CODE_REPETITION = 1012;    //验证码重复发送
    public static final int CODE_PASSWORD_ERROR = 1013;     //密码错误
    public static final int CODE_MAIL_ALREADY_EXISTS = 1014;    //邮箱已被使用
    public static final int CODE_IDENTITY_CARD_ALREADY_EXISTS = 1015;   //该身份证已被认证
    public static final int CODE_PICTURE_FORMAT_ERROR = 1016;   //图片大小或格式不正确
    public static final int CODE_PICTURE_BIG = 10167;   //图片大小不得高于3M
    public static final int CODE_1040 = 1040;   //订单已评价
    public static final int CODE_PAY_PASSWORD_NOT_SET = 1034;   //资金密码没有设置
    public static final int CODE_BANK_NUM_INCORRECT = 1048;   //资金密码没有设置
    public static final int CODE_NOT_RECEIVER_MY = 1060; //不能接受自己的单
    public static final int CODE_OTHER_LOGIN = 4002;   //账号在别处登录
    public static final int CODE_PAY_PASSWORD_NOT_PASS = 1031;   //验证不通过
    public static final int CODE_1032 = 1032;   //完成初级验证||行名有误
    public static final int CODE_PLEASE_PRIMARY_AUTH = 1033;   //完成初级验证||行名有误
    public static final int CODE_BANK_INCORRECT = 1044;   //银行名有误
    public static final int CODE_AFTER_15 = 1066;   //下单后15分钟才可确认
    public static final int CODE_WAIT = 3013;   //已将订单入库等待匹配!
    public static final int CODE_VERSION_DIFFERENT = 6000;   //已将订单入库等待匹配!
    private int mCode;
    private String mMsg = "未知错误";
    private Context mContext = Utils.getContext();

    public ApiException() {
        this(CODE_OPERATION_FAILURE);
    }


    public ApiException(int code) {
        super();
        this.mCode = code;
    }

    public ApiException(int code, String message) {
        super(message);
        this.mCode = code;
        this.mMsg = message;
    }

    public ApiException(int code, Throwable cause) {
        super(cause);
        mCode = code;
    }

    public ApiException(int code, String message, Throwable cause) {
        super(message, cause);
        this.mCode = code;
        this.mMsg = message;
    }

    public int getCode() {
        return mCode;
    }

    public String getMsg() {
        return mMsg;
    }

    public void setCode(int code){
        this.mCode=code;
    }

    public void setMsg(String msg){
        mMsg=msg;
    }
}
